package com.tjshop.android.model.tj.json;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.tjshop.android.model.BaseObject;

public class HomeCategory extends BaseObject implements Serializable {

	private List<HomeCategoryItem> items = new ArrayList<HomeCategoryItem>();

	public List<HomeCategoryItem> getItems() {
		return items;
	}

	public void setItems(List<HomeCategoryItem> items) {
		this.items = items;
	}

	@Override
	public void parse(JSONObject data) {

	}

	@Override
	public void parse(JSONArray data) {
		for (int i = 0; i < data.length(); i++) {
			HomeCategoryItem item = new HomeCategoryItem();
			try {
				item.parse(data.getJSONObject(i));
			} catch (JSONException e) {
				e.printStackTrace();
			}
			items.add(item);
		}
		HomeCategoryItem item = new HomeCategoryItem();
		item.setCat_id("-1");
		item.setCat_name("我的订单");
		item.setNpos("7");
		items.add(item);
		item = new HomeCategoryItem();
		item.setCat_id("-1");
		item.setCat_name("全部");
		item.setNpos("8");
		items.add(item);
		Collections.sort(items);
	}

}
